{include file="public/header" /}
<div class="page">
    <div class="fixed-empty"></div>
    <form id="post_form" method="post" action="{url('Casue/edit_reason')}" name="articleClassForm">
        <input type="hidden" class="hidden" name="reason_id" value="{$reason.id|default=''}">
        <table class="ds-default-table">
            <tbody>

            <tr class="noborder">
                <td class="required w150"><label class="validation" for="member_name">原因:</label></td>
                <td class="vatop rowform"><input type="text" value="{$reason.info}"  name="info" id="reason_info" class="txt">
                <td class="vatop tips"></td>
            </tr>

            <tr class="noborder">
                <td colspan="required w150" class="required">
                    <label class="validation" for="reason_sort">类型:</label>
                  <td class="vatop rowform">
                    <select name="type" id="type">
                            <option value="1"
                            <?php if(isset($reason) && $reason['type']==1){?>
                            selected="selected"<?php }?>
                            >拒单</option>
                            <option value="2"
                            <?php if(isset($reason) && $reason['type']==2){?>
                            selected="selected"<?php }?>
                            >更换服务人员</option>
                            <option value="3"
                            <?php if(isset($reason) && $reason['type']==3){?>
                            selected="selected"<?php }?>
                            >客户端取消订单</option>
                            <option value="4"
                            <?php if(isset($reason) && $reason['type']==4){?>
                            selected="selected"<?php }?>
                            >追加工时</option>
                            <option value="5"
                            <?php if(isset($reason) && $reason['type']==5){?>
                            selected="selected"<?php }?>
                            >服务端取消订单</option>
                        </select>
                  </td>
                </td>
            </tr> 


            <tr class="noborder">
                <td class="required w150"><label class="validation" for="member_name">排序:</label></td>
                <td class="vatop rowform"><input type="text" value="{$reason.sort}" name="sort"  id="reason_sort"  class="txt">
                  <td class="vatop tips"></td>
            </tr>

            <tr class="noborder">
                <td class="required w150"><label  for="ac_name">状态:</label></td>
                <td class="vatop rowform onoff">
                    <label for="site_state1"
                                   class="cb-enable <?php if(isset($reason) && $reason['status']==1){?> selected <?php }else if(!isset($reason)){echo 'selected';}?>">{$Think.lang.ds_open}</label>
                            <label for="site_state0"
                                   class="cb-disable <?php if(isset($reason) && $reason['status']==0){?> selected <?php }?>">{$Think.lang.ds_close}</label>
                            <input id="site_state1" name="status" value="1"
                                   type="radio" <?php if(isset($reason) && $reason['status']==1){?>
                            checked="checked"<?php }else if(!isset($reason)){?> checked="checked" <?php }?>  >
                            <input id="site_state0" name="status" value="0"
                                   type="radio" <?php if(isset($reason) && $reason['status']==0){?>
                            checked="checked"<?php }?>  >
                </td>
            </tr>
            </tbody>
            <tfoot>
            <tr class="tfoot" style="text-align: center;">
                <td colspan="15" ><input style="display:inline-block;border:none;padding:0px 18px;height:38px;line-height:38px;border-radius:3px;background-color:#419dfd;color:#fff!important;vertical-align:middle;text-align:center;cursor:pointer;font-size: 14px;" class="btn" type="submit" value="{$Think.lang.ds_submit}"/></td>
            </tr>
            </tfoot>
        </table>
    </form>
</div>
<script type="text/javascript" src="{$Think.PLUGINS_SITE_ROOT}/mlselection.js" charset="utf-8"></script>
<script type="text/javascript" src="{$Think.PLUGINS_SITE_ROOT}/jquery.mousewheel.js"></script>
<script>
    //按钮先执行验证再提交表单
    $(document).ready(function () {
        $("#post_form").validate({
            errorPlacement: function (error, element) {
                error.appendTo(element.parent().parent().find('td:last'));
            },
            rules: {
                reason_info: {
                    required: true,
                    remote   : {
                        url :"{:url('Brand/ajax','branch=check_goods')}",
                        type:'get',
                        data:{
                            brand_name : function(){
                                return $('#reason_info').val();
                            },
                        }
                    }
                },
                reason_sort: {
                    required: true,
                    digits: true,
                    range: [0, 255]
                }
            },
            messages: {
                reason_info: {
                    required: "{$Think.lang.reason_info_required}",
                    remote   : '原因不可以重复哦~'
                },
                reason_sort: {
                    required: "{$Think.lang.reason_sort_digits}",
                    digits: "{$Think.lang.reason_sort_digits}",
                    range: '{$Think.lang.reason_sort_tips}'
                }
            }
        });

        /*  $("form").submit(function (e) {
              var res = $("#goods_class_form").valid();
              if (res) {
                  var url = $('form').attr('action');
                  $.ajax({
                      type: "POST",
                      url: url,
                      data: $('#goods_class_form').serialize(),// 你的formid
                      error: function (request) {
                          alert("Connection error");
                      },
                      success: function (result) {
                          if (result.code == 0) {
                              layer.msg(result.msg);
                              location.href = result.url;
                              return false;
                          } else {
                              layer.msg(result.msg);
                              location.href = result.url;
                              return false;
                              s

                          }
                      }
                  });
                  return false;


              }

          });*/


    });

</script>
